1. Field of the Invention
The present invention relates to a flash memory, and in particular, to a data storage device having a flash memory and a garbage collection method for a flash memory.
2. Description of the Related Art
Flash memory is a common non-volatile data storage device, which can be erased and programmed electrically. For example, an NAND flash memory is usually for use in a memory card, a USB flash device, a solid-state disk (SSD), an embedded multimedia card, etc.
A storage array of a flash memory may comprise a plurality of blocks, and each block comprises a plurality of pages. When a used block is to be released as a spare block, all pages of the used block have to be erased in the operation. The technique of garbage collection is used to move the valid data located in various blocks to a spare space, so that the blocks only contain invalid data and can be erased and released as spare blocks.
However, a lot of resources and computations are required when using conventional garbage collection methods, resulting in incapability of performing a wear-leveling process on flash memory.